<!DOCTYPE html>
<html lang="en">
<head>
    <script src="jquery-3.3.1.min.js"></script>

  <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <title>程序猿嘚吧嘚</title>
    <link rel="stylesheet" href="homePage.css">
    <!--&lt;!&ndash;引入JQ&ndash;&gt;<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>-->
    <style>
        #durationbar{
            width: 500px;
            height: 20px;
        }
        #durationbar progress{
            width: 100%;
            height: 100%;
        }
    </style>


<script>


    function myFunction() {
        var x = document.getElementById("demo").value;
        if (x == ""||isNaN(x))
        {
            alert("不对劲");
        }else {
            alert("bingo");


        }
    }


    function changeTitle(){

        document.getElementById("title").innerHTML="更改文字";

    }


    function fun()
    {
    try
    {
            var x = document.getElementById("demo").value;
        if(x=="")    throw "值为空";
        if(isNaN(x)) throw "不是数字";
        if(x>10)     throw "太大";
        if(x<5)      throw "太小";
    }
    catch(err)
    {
        var y=document.getElementById("mess");
        y.innerHTML="错误：" + err + "。";
    }

    }


    function mOver(obj)
    {
        obj.innerHTML="谢谢"
    }

    function mOut(obj)
    {
        obj.innerHTML="把鼠标移到上面"
    }

    function fun() {



        // jQuery.getJSON( url [, data ] [, success ] )
        $.getJSON("cinema_list.json", "", function (data) {

            if (parseInt(data.retcode) === 200) {
                var searchKeyWord = document.getElementById("demo").value;
                var searchNumber = 0;
                var goodsList = document.getElementById('goods-list');
                goodsList.innerHTML = "";
                for (var i = 0; i < data.cinemaList.length; i++) {

                    var regExp = new RegExp(searchKeyWord, "ig");
                    if (!regExp.test(data.cinemaList[i].name)) continue;
                    var goodsNodeElement = document.createElement("div");
                    goodsNodeElement.innerHTML = data.cinemaList[i].name + " " + data.cinemaList[i].lowPrice;

                    console.log( data.cinemaList[i].name );  // true
                    goodsList.appendChild(goodsNodeElement);
                    searchNumber++;

                }
                if (searchNumber <= 0) {
                    alert("暂无此商品");
                }
            }


            var count = 1;
            var arr = data.cinemaList;








        }, "json");

    }

    //each循环 使用$.each方法遍历返回的数据date
    //            $.each(data.cinemaList, function (i, item) {
    //                var str = '<div>商品名称:' + item.name + '价格：' + item.lowPrice + '</div>';
    //                document.write(str);
    //               var str_name = item.name;
    //               var x = document.getElementById("demo").value;
    ////
    ////                if(str_name.indexOf(x)!=-1){
    ////                    // 包含
    ////                    document.write(str);
    //                  console.log(str );  // true
    ////               //不等于-1表示该字符串包含子字符串。
    ////
    ////                }else {
    ////
    ////
    ////
    ////                }
    //
    //
    //
    //
    //
    //
    //            })


</script>

    <script type="text/javascript">
        var c=0
        var t

        function timedCount()
        {
            document.getElementById('txt').value=c
            c=c+1
            t=setTimeout("timedCount()",1000)
        }

        function stopCount()
        {
            clearTimeout(t)
        }



    </script>





    </head>



<!--<input><br>-->
<!--<br>-->
<!--<br>-->
<!--<a href="itms-services://?action=download-manifest&url=https://tanghk.gitee.io/manifest.plist">点击在线安装ipa</a><br>-->
<!--<br>-->
<!--<a href="https://tanghk.gitee.io/otouzi.png">点击打开图片 </a>-->
<!--<br>-->
<!--<br>-->
<!--<a href="https://tanghk.gitee.io/ios_distribution.cer">测试证书 </a>-->
<!--<br>-->

<!--<p>ttnaingaa </p>-->



<!--<br>-->


<!--<button type="button" onclick="alert('hi')">点这里</button>-->
<!--<br>-->

<!--<p id="title">哈哈哈哈</p>-->
<!--<form>-->
<!--<input type="button" value="Start count!" onClick="timedCount()">-->
<!--<input type="text" id="txt">-->
<!--<input type="button" value="Stop count!" onClick="stopCount()">-->
<!--</form>-->
<!--<button type="button" onclick="alert('你好漂亮')">点我试试</button>-->
<!--<button type="button" onclick="alert('你好美丽')">按我一下</button>-->
<!--<div onmouseover="mOver(this)" onmouseout="mOut(this)" style="background-color:green;width:120px;height:20px;padding:40px;color:#ffffff;">把鼠标移到上面</div>-->

<p>你好</p>
<br>



<input id="demo" placeholder = "请输入商品名称" type="text">

<button type="button" onclick="fun()">确定</button>
<p id="mess"></p>
<p>例如：北京 、电影、电影院</p>
<div id="goods-list"></div>
<br>




</body>
</html>










































